﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.gaiaonline.monster.controller.application {
    import com.gaiaonline.monster.model.vo.*;
    import alecmce.ui.*;
    import com.gaiaonline.monster.model.*;
    import alecmce.async.*;
    import com.gaiaonline.monster.events.*;
    import com.gaiaonline.monster.service.process.*;
    import gaia.moga.assets.*;
    import gaia.moga.inventory.model.*;
    import gaia.moga.items.model.*;
    import com.gaiaonline.monster.controller.*;
    import com.gaiaonline.monster.view.components.tutorial.*;
    import gaia.moga.*;

    public class InvokeBattleTutorialCommand extends AsyncCommand {

		[Inject]
        public var assets:AssetService;
		[Inject]
        public var monsters:MonsterAssetsFactory;
		[Inject]
        public var inventory:InventoryModel;
		[Inject]
        public var ranchModel:HomeRanchModel;
		[Inject]
        public var updateUserData:UpdateUserData;
        private var _tutorialAsset:Asset;

        private static const TUTORIAL_ASSET:String = "assets/tutorial/tutorial.swf";

        override public function execute():void{
            this._tutorialAsset = this.assets.createWrapper(TUTORIAL_ASSET);
            var _local1:ParallelAsyncs = new ParallelAsyncs("InvokeBattleTutorial-Parallel");
            _local1.add(this.updateUserData);
            _local1.add(this._tutorialAsset);
            hook(_local1, this.onComplete, this.onError);
        }
        private function onComplete(_arg1:Async):void{
            var _local2:MonsterModel = this.ranchModel.mogas[0];
            var _local3:BattleTutorialVO = new BattleTutorialVO();
            _local3.numSeeds = this.inventory.getItem(ItemEnum.SEED).quantity;
            _local3.numRecharges = this.inventory.getItem(ItemEnum.COFFEE).quantity;
            _local3.numWhistles = this.inventory.getItem(ItemEnum.WHISTLE).quantity;
            _local3.monsterModel = this.ranchModel.mogas[0];
            _local3.bundle = this.monsters.monsterBundle(_local2);
            _local3.tutorialAsset = this._tutorialAsset;
            var _local4:BattleTutorial = new BattleTutorial(_local3);
            dispatch(new PanelsEvent(PanelsEvent.SET_PANEL, _local4));
        }
        private function onError(_arg1:Async, _arg2:String=""):void{
            dispatch(new CatastrophicErrorEvent(CatastrophicErrorEvent.ERROR, Errors.UNABLE_TO_INVOKE_BATTLE_TUTORIAL));
        }

    }
}//package com.gaiaonline.monster.controller.application 
